package org.aphasia4j.dao.impl;

import java.util.List;

import org.aphasia4j.dao.PatientDao;
import org.aphasia4j.dao.core.BaseDaoSupport;
import org.aphasia4j.model.Patient;

/**
 * Implementation of the {@link PatientDao} interface description.
 * 
 * @author hillger.t
 */
public class PatientDaoImpl extends BaseDaoSupport<Patient> implements PatientDao {

  @Override
  @SuppressWarnings("unchecked")
  public List<Patient> getPatientsByName(String namePart) {
    namePart = null == namePart ? "" : namePart;
    String jql = "select p from Patient p where lower(p.lastname) like ?";
    return this.getJpaTemplate().find(jql, namePart + "%");
  }
}
